<?php

namespace IDock\Insurance\JTIC\Request;

use IDock\Insurance\JTIC\JTICEnums;
use IDock\Insurance\JTIC\Response\LNewVehicleRegistrationResponse;
use IDock\Visitor\Premium\PremiumInquiryVisitor;

class LNewVehicleRegistrationRequest extends AllJTICRequest
{
    protected $code = 'V110';

    protected $response = LNewVehicleRegistrationResponse::class;

    protected $urlTip = '新车备案';

    /*** @var  PremiumInquiryVisitor $visitor */
    protected $visitor;

    public function generate(): array
    {
        JTICEnums::getUsageTypeCode(
            $this->visitor->getVehicleVisitor()->useNatureCode,
            $this->visitor->getVehicleVisitor()->causeType,
            $this->visitor->getVehicleVisitor()->carKindCode,
            $this->visitor->getVehicleVisitor()->vehicleSeat,
            $this->visitor->getVehicleVisitor()->vehicleTonnage,
            $motorUsageTypeCode,
            $motorTypeCode
        );

        return [
            'NewCarRegistration' => [
                'DeptTeamCode' => $this->visitor->getExtInfoVisitor()->argc['DeptTeamCode'] ?? '',
                'EngineNo' => $this->visitor->getVehicleVisitor()->engineNo,
                'VIN' => $this->visitor->getVehicleVisitor()->vin,

                'VehicleOwnerName' => $this->visitor->getOwnerVisitor()->name,
                'VehicleOwnerCertfCls' => JTICEnums::$certificateTypeCode[$this->visitor->getOwnerVisitor()->certificateTypeCode],
                'VehicleOwnerCertfCode' => $this->visitor->getOwnerVisitor()->certificateNo,

                'TrafficVehicleType' => $this->visitor->getVehicleVisitor()->vehicleStyleCode,

                'VehicleSeat' => $this->visitor->getVehicleVisitor()->vehicleSeat,
                'VehicleTonnage' => round($this->visitor->getVehicleVisitor()->vehicleTonnage / 1000, 2),
                'WholeWeight' => $this->visitor->getVehicleVisitor()->wholeWeight,
                'VehicleExhaust' => $this->visitor->getVehicleVisitor()->vehicleExhaust,

                'PmFuelType' => '',
                'CertificateType' => $this->visitor->getVehicleVisitor()->carCertificateType,
                'CertificateNo' => $this->visitor->getVehicleVisitor()->carCertificateNo,
                'CertificateDate' => $this->visitor->getVehicleVisitor()->carCertificateDate,
                'MotorTypeCode' => $motorTypeCode,
                'FuelType' => JTICEnums::$energyType[$this->visitor->getVehicleVisitor()->energyTypeCode],
                'VehicleModel' => $this->visitor->getVehicleVisitor()->vehicleModelCode,
            ],
        ];
    }
}
